/**
 * @Author: 焦质晔
 * @Date: 2019/6/20
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2019-08-30 10:10:53
 */
import Cookies from 'js-cookie';
import JSEncrypt from 'jsencrypt';

const TokenKey = 'jwt';
const EncryptKey =
  'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC+qyoKFVePsvGQ9/RJJC9FT9FYF6kxuJ1l53P8GHMzTU9Jbbk2k///Hf5cpX8iP6laV24OT1KGLab/kUuUlT+1BSR4OsAUshASqYQbvzqSHn8DWJ9owovh3461Rksc1uS2xGABKzjcDi3nwHLkJ50bSLWpRxAKA+6TXo7mH0E4bQIDAQAB';

//存储账户信息
export const setDataType = dataType => Cookies.set('dataType', dataType);
export const getDataType = () => Cookies.get('dataType');
export const removeDataType = () => Cookies.remove('dataType');

export const setAppId = appId => Cookies.set('appId', appId);
export const getAppId = () => Cookies.get('appId');
export const removeAppId = () => Cookies.remove('appId');

// 存储 token
export const getToken = () => Cookies.get(TokenKey);

export const setToken = token => Cookies.set(TokenKey, token);

export const setUserOrgId = userOrgId => Cookies.set("cmsUserOrgId", userOrgId);

export const getUserOrgId = () => Cookies.get('cmsUserOrgId');

export const removeToken = () => Cookies.remove(TokenKey);

// 存储用户名
export const getUser = () => Cookies.get('username');

export const setUser = name => Cookies.set('username', name);

export const removeUser = () => Cookies.remove('username');

// RSA 加密
export const jsEncrypt = str => {
  const encrypt = new JSEncrypt();
  encrypt.setPublicKey(EncryptKey);
  return encrypt.encrypt(str);
};

//旧的百度地图ak
// export const AK='crO4GfGoPVD0zgoEIgTAKO35pUTiKhGf';
//2020-02-26   客户提供的百度地图ak
export const AK = 'WQZZbz0xXzAHa7hmIX1SHeDvj6cVQC7L';
// 储存userid
export const getUserId = () => Cookies.get('userId');

export const setUserId = userId => Cookies.set('userId', userId);

// 储存employeeNo
export const getEmployeeNo = () => Cookies.get('employeeNo');

export const setEmployeeNo = employeeNo => Cookies.set('employeeNo', employeeNo);

//储存company_id
export const getCompanyId = () => Cookies.get('companyId');

export const setCompanyId = companyId => Cookies.set('companyId', companyId);

//储存 owner_code
export const getOwnerCode = () => Cookies.get('ownerCode');

export const setOwnerCode = ownerCode => Cookies.set('ownerCode', ownerCode);
